package webmanage

import (
	"context"
	"github.com/go-kratos/kratos/v2/log"
	"gorm.io/gorm"
	"phm/models/generator/model"
)

type SysUserAreaRepo interface {
	CreateSysUserArea(ctx context.Context, uModel *model.SysUserArea, db *gorm.DB) error
	UpdateSysUserArea(ctx context.Context, uModel *model.SysUserArea, db *gorm.DB) error
	DeleteSysUserAreaByIds(ctx context.Context, ids []string, db *gorm.DB) error
	GetSysUserAreaById(ctx context.Context, id string) (*model.SysUserArea, error)
	GetSysUserAreaByIds(ctx context.Context, ids []string) ([]*model.SysUserArea, error)
	GetSysUserAreaList(ctx context.Context, query string, pageNum, pageSize int64) ([]*model.SysUserArea, int64, error)
	// GetDB 得到db以方便事务处理
	GetDB() *gorm.DB
	GetSysAreaByUserId(ctx context.Context, id string) ([]*model.RaServerArea, error)
}

type SysUserAreaUseCase struct {
	sysUserArea SysUserAreaRepo
	log         *log.Helper
}

func NewSysUserAreaUseCase(sysUserArea SysUserAreaRepo, logger log.Logger) *SysUserAreaUseCase {
	return &SysUserAreaUseCase{
		sysUserArea: sysUserArea,
		log:         log.NewHelper(logger),
	}
}
